<template>
  <div  class="section-wrap" style="height:100%;padding-top: 40px">
    <!-- 头部 -->
    <div class="headerBox">
      <div class="header">
        <x-icon type="ios-arrow-left" size="" class="icon-white" @click="goBack"></x-icon>
        检查计划审批
      </div>
    </div>
     <vue-better-scroll
      class="wrapper"
      ref="scrollqq"
      :scrollbar="scrollbarObj"
      :pullDownRefresh="pullDownRefreshObj"
      :pullUpLoad="pullUpLoadObj"
      :startY='parseInt(startY)'
      @pullingUp="onPullingUp"
    >
    <div class="form-section" style="margin-top: 40px;">
      <div class="info_div2">
        <div class="form-item">
          <div>
            <span>待审批检查计划：{{plantotalcount}}次</span>
          </div>
        </div>
      </div>
      <div class="project_div">
        <ul class="project_list">
          <li v-for="(item,index) in resultlist" :key="index" @click="getInfo(item.id)">
            <h4 style="padding-top:2px;">{{item.projectName}}</h4>
            <p style="width:90%;overflow:hidden;">
              <span style="float:left;width:60%;overflow:hidden;text-overflow:ellipsis;white-space: nowrap;padding-top:2px;">{{item.checkType}}</span>
              <span v-if="item.checkDate" style="float:right;padding-top:2px;" class="project_time">{{item.checkDate.substring(0,10)}}</span>
            </p>
            <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
          </li>
        </ul>
      </div>
      
    </div>
     </vue-better-scroll>
  </div>
</template>
<script>
import formatDate from "../../utils/formatDate";
import {
  XHeader,
  Tabbar,
  TabbarItem,
  Group,
  Cell,
  TransferDom,
  Popup
} from "vux";
import VueBetterScroll from "vue2-better-scroll";
export default {
  data() {
    return {
      isDisabled: true, // 是否禁止输入
      plantotalcount: 0,
      detailData: {
        ResolveStartTime: "2019-07-01",
        ResolveEndTime: "2019-08-29",
        DeptName1: "全部",
        DeptName2: "北京华电豆粒有限公司"
      },
      resultlist: [],
    
      queryparam: {
        isPlan: 1,
        isGetAll: 0,
        skipCount: 0,
        maxResultCount: 1000
      },
      scrollbarObj: { fade: true },
      pullDownRefreshObj: false,
      pullUpLoadObj: {
        threshold: 0,
        txt: {
          more: "加载更多",
          noMore: "没有更多数据了"
        }
      },
      startY: 0,
      scrollToX: 0,
      scrollToY: 0,
      scrollToTime: 700
    };
  },
  components: {
    VueBetterScroll,
    XHeader,
    Tabbar,
    TabbarItem,
    Group,
    Cell,
    TransferDom,
    Popup
  },
  created() {
    this.getAssessmentPlan();
  },
  mounted() {
    let that = this;
    this.$bridge.registerHandler("setToken", function(data) {
      that.$store.state.Authorization = "Bearer " + data;
      //这里data ioS返回的是token值(字符串)
    });
    this.connectWebViewJavascriptBridge(function(bridge) {
      bridge.init(function(message, responseCallback) {});
      bridge.registerHandler("setToken", function(data) {
        that.$store.state.Authorization = "Bearer " + data;
        //这里data android返回的是token值(字符串)
      });
    });
  },
  methods: {
    connectWebViewJavascriptBridge(callback) {
      if (window.WebViewJavascriptBridge) {
        callback(WebViewJavascriptBridge);
      } else {
        document.addEventListener(
          "WebViewJavascriptBridgeReady",
          function() {
            callback(WebViewJavascriptBridge);
          },
          false
        );
      }
    },
    getAssessmentPlan() {
      this.queryparam.checkDepartId = this.$store.state.departId
      this.$axiosAjax
        .querycheckPlanAssess(this.queryparam)
        .then(res => {
              if (res.data.success == true) {
              
            let relist = res.data.result.items;
            this.resultlist = this.resultlist.concat(relist);
            let totalAllCount = res.data.result.totalCount;
            this.plantotalcount=totalAllCount;
            let resultCount = this.resultlist.length;
            if (parseInt(resultCount) < parseInt(totalAllCount)) {
              this.$refs['scrollqq'].forceUpdate(true);
            } else {
              this.$refs['scrollqq'].forceUpdate(false);
            }
          }
          
        }).catch(
          (err) => {

          }
        )
      },
        onPullingUp() {

        let limitcount = this.resultlist.length;
        this.queryparam.skipCount = limitcount;
        this.getAssessmentPlan();
      },
    goBack() {
      this.$bridge.callHandler({
        type: "closePage",
        data: {}
      });
    },
    getInfo(val){
     
      this.$router.push({path:'/checkPlanAssessEdit',query:{id:val}});
    }
  }
};
</script>
<style lang="less" scoped>
.info_div2 {
  border-top: none;
  .form-item {
    span {
      font-weight: bold;
    }
  }
}
.project_div {
  .project_list {
    padding-left: 20px;
    li {
      border-bottom: 1px solid #efeff4;
      height: 77px;
      position: relative;
      padding-top: 18px;
      padding-right: 22px;
      h4 {
        width: calc(100% - 40px);
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        font-size: 16px;
        margin-bottom: 8px;
        font-weight: bold;
      }
      p {
        span {
          font-size: 14px;
          color: #666;
        }
        span:first-child {
          margin-right: 40px;
        }
      }
      .project_status {
        margin-top: 14px;
        strong {
          font-size: 12px;
        }
        strong.project_status1 {
          color: #ff7333;
        }
        strong.project_status2 {
          color: #469b7a;
        }
      }
      .vux-x-icon {
        fill: #999;
        right: 20px;
        top: 50%;
        margin-top: -11px;
        position: absolute;
      }
    }
  }
}
</style>
